Add UART receive interrupt handler#147
Conversation
|
@ThomasAkam bumping this in case you missed it. No rush though. |
|
Thanks Andy, and apologies for the delay in getting to this - I've been swamped the last month. This does look like useful functionallity but would it be possible to put it in a UART_handler device rather than in hardware.py? This would avoid increasing the size of the framework which is desirable on the pyboard v1.1 due to the limited memory resources. |
|
No worries at all! Thanks for taking a look. I moved the code into a separate device file |
|
Hi @ThomasAkam, a friendly reminder to consider this and the other pending pull requests when you get a chance. |
|
Thanks Andy, merging now. If you get time to add something to the hardware docs describing this functionallity that would be great. Also, the hardware.py file seems to be formatted slightly differently from how my Black formatter likes it. Apologies again for the very belated response! |
I have a custom syringe pump that uses UART serial messages to communicate with pyControl. It is sometimes useful to receive messages from the pump, for instance to tell the task that a syringe is empty, so the task will automatically stop.
Previously, to get this working would require constant polling the syringe pump UART to see if there were any messages available. Something like:
This pull request adds a
UART_handlerclass that can be attached to a UART's RX interrupt. Now a pyControl framework event will be output whenever a UART message is received. So the task code now looks something like this:This gets rid of the constantly polling timer and greatly reduces response time.
Here is a look at my PumpController device class to see how it is implemented:
This improves the situation described in the docs